<?php $this->load->view("common/page_header");?>
<div id="body_main">	
	<div class="login_header">
		<img class="logo" src="../../../img/logo2.png" />
		<div class="title">注册行家</div>
		<div class="action"><a href="<?php echo site_url("user/show");?>">行动中心</a></div>
		<div class="clear"></div>
	</div>
	<div class="login_body" style="background:none">
		<div class="arrow_up">
			<em>◆</em>
			<span>◆</span>
		</div>
		<?php echo validation_errors(); ?>
		<form class="margin_top15 margin_left15" method="post" onsubmit="return is_form_valid();">
			<div class="form_row">
				<label class="input_label"><span class="red">*</span> 行家名称：</label>
				<input type="text" class="input_text_short" name="title" id="expert_title" value="<?php echo empty($title)? '' : $title;?>"/>
				<span class="grey margin_left15">不超过9个字，例如：心理咨询师</span>
				<div class="form_error"></div>
			</div>
			<div class="form_row">
				<label class="input_label"><span class="red">*</span> 服务报价：</label>
				<input type="text" class="input_text_short" name="price" value="<?php echo empty($price)? '' : $price;?>"/>
				<span class="grey margin_left15">对您的服务标价，例如：200元/小时。不填则默认为：面议</span>
			</div>
			<div class="form_row">
				<label class="input_label">行家类型：</label>
				<select class="section_selector">
					<option value="">行业类别</option>
					<?php foreach($first_level_categories as $category) {?>
					<option value="<?php echo $category['id']?>" <?php if(!empty($first_level_category_id) && $first_level_category_id == $category['id']) echo "selected";?>>
					<?php echo $category['name']?></option>	
					<?php }?>
				</select>
				<select name="second_category_id" id="category_id" class="category_selector">
					<option value="">行家分类</option>
				</select> 
				<select name="category_id" id="third_category_id">
					<option value="">行家分类</option>
				</select>
			</div>
			<div class="form_row">
				<label class="input_label">发布地区：</label>
				<?php $this->load->view("common/province_selector");?>
			</div>
			<div class="form_row">
				<label class="input_label">专业描述：</label>
				<textarea class="input_textarea" name="description" id="expert_description"><?php echo empty($description)? '' : $description;?></textarea>
				<div class="input_hint">（50-500字）例如所获得的奖项、资格认证、所参加过的专业培训等所有可表现自己专业水准的经历</div>
				<div class="form_error"><div class="error_icon"></div>专业描述要在50-500个字内</div>
			</div>
			<div class="form_row">
				<label class="input_label">主要成就：</label>
				<textarea class="input_textarea" name="introduction" id="expert_introduction"><?php echo empty($introduction)? '' : $introduction?></textarea>
				<div class="input_hint">（10-1500字）例如具体做过哪些事项，分别取得什么成效等，尽量用数字说明。</div>
				<div class="form_error"><div class="error_icon"></div>主要成就要在10-1500个字内</div>
			</div>
			<div class="form_action">
				<input type="hidden" name="id" value="<?php echo (empty($id) ? '' : $id);?>" />
				<input type="submit" value="提交注册" class="input_button"/>
			</div>
			
		</form>
		<div class="clear"></div>
	</div>
</div>
<?php $this->load->view("common/footer");?>		
<?php $this->load->view("common/page_footer");?>
<script type="text/javascript">
function is_form_valid() {
	var has_error = false;

	var expert_title = $('#expert_title');
	var title = expert_title.val();
	if (title == '') {
		has_error = true;
		expert_title.parent().find('.form_error').html('<div class="error_icon"></div>行家名称不能为空').show();
	} else if (title.length > 9) {
		has_error = true;
		expert_title.parent().find('.form_error').html('<div class="error_icon"></div>行家名称要在9个字内').show();
	} else {
		expert_title.parent().find('.form_error').hide();
	}

	var expert_description = $('#expert_description');
	var description = expert_description.val();
	if (description.length != '' && (description.length < 50 || description.length > 500)) {
		has_error = true;
		expert_description.parent().find('.form_error').show();
	} else {
		expert_description.parent().find('.form_error').hide();
	}
	
	var expert_introduction = $('#expert_introduction');
	var introduction = expert_introduction.val();
	if (introduction != '' && (introduction.length < 10 || introduction.length > 1500)) {
		has_error = true;
		expert_introduction.parent().find('.form_error').show();
	} else {
		expert_introduction.parent().find('.form_error').hide();
	}

	return !has_error;
}
$(document).ready(function(){
	<?php if(!empty($category_id)) {?>
		var second_level_category_id = <?php echo $second_level_category_id;?>;
		$.get( '/front/find_sub_categories_ajax', {section_id:<?php echo $first_level_category_id?>}, function(data) {
			var ret = eval('(' + data + ')'); 
			var html = '';
			for (var x in ret) {
				html += '<option value="' + ret[x].id + '"' + (ret[x].id == second_level_category_id ? 'selected' : '')+ '>' + ret[x].name + '</option>';
			}
			$('#category_id').html(html);
			
		});
		$.get( '/front/find_sub_categories_ajax', {section_id:second_level_category_id}, function(data) {
			var ret = eval('(' + data + ')'); 
			var html = '';
			for (var x in ret) {
				html += '<option value="' + ret[x].id + '"' + (ret[x].id == <?php echo $category_id;?> ? 'selected' : '')+ '>' + ret[x].name + '</option>';
			}
			$('#third_category_id').html(html);
		});
	<?php }?>
	$("#register_button").colorbox({iframe:true, innerWidth:556, innerHeight:320, close:'关闭'});
	$("#login_button").colorbox({iframe:true, innerWidth:390, innerHeight:180, close:'关闭'});
});	
</script>